#ifndef CAMERATHREAD_H
#define CAMERATHREAD_H

#include <QThread>
#include <QImage>
#include <opencv2/opencv.hpp>
#include <QDebug>
#include <memory>
#include <QPointer>

class CameraThread : public QThread
{
    Q_OBJECT
public:
    static CameraThread* getInstance();
    //级联分类器人脸编制边框
    void detecFaceRaw(cv::Mat &frame, cv::CascadeClassifier &cascade, double scale);
    //视频初始化
    void videoInit();

    bool getIsRun() const;
    void setIsRun(bool value);

    bool getIsStop() const;
    void setIsStop(bool value);

    void setSleep(unsigned long value);

private:
    CameraThread();
    static CameraThread *camThread;
    bool isRun;
    bool isStop;
    unsigned long sleep;

    QImage img;
    cv::VideoCapture *cap;
    cv::Mat frame;

signals:
    void sendImg(QImage);   //发送画面给QWidget

    // QThread interface
protected:
    void run();
};

#endif // CAMERATHREAD_H
